<template>
  <div>
    <el-collapse v-model="searchActiveName" accordion>
      <el-collapse-item name="first" class="center-title">
        <template slot="title">
          <i style="color: #409eff; text-align: center; width: 100%;  " class="el-icon-search  "> 过滤条件 -
            {{searchActiveName=='first'?'点击关闭':'点击打开'}} </i>
        </template>
        <el-card class="box-card">
          <el-form ref="queryForm" size="small" inline label-width="120px">
            <el-form-item label="文件容量:" prop="nasname">
              <el-input v-model="queryForm.fileMinSize" style="width: 120px" type="number" min="0" placeholder="最小"
                clearable></el-input>
              至<el-input v-model="queryForm.fileMaxSize" style="width: 120px" type="number" min="0" placeholder="最大"
                clearable></el-input>
              <el-radio-group @change="handleRadioChange" v-model="queryForm.unitradio" size="mini">
                <el-tooltip class="item" effect="dark" content="文件容量以 B 为单位开始过滤" placement="top-start">
                  <el-radio-button border :label="1">B</el-radio-button></el-tooltip>
                <el-tooltip class="item" effect="dark" content="文件容量以 KB 为单位开始过滤" placement="top-start">
                  <el-radio-button border :label="1024">KB</el-radio-button></el-tooltip>
                <el-tooltip class="item" effect="dark" content="文件容量以 MB 为单位开始过滤" placement="top-start">
                  <el-radio-button border :label="1024*1024">MB</el-radio-button></el-tooltip>
                <el-tooltip class="item" effect="dark" content="文件容量以 GB 为单位开始过滤" placement="top-start">
                  <el-radio-button border :label="1024*1024*1024">GB</el-radio-button></el-tooltip>
              </el-radio-group>
            </el-form-item>
            <el-form-item
              :label="queryForm.dateradio=='createTime'?'创建日期':queryForm.dateradio=='lastAccess'?'最后访问日期':'最后修改日期'"
              prop="nasIp">
              <el-date-picker v-model="queryForm.dateTime" type="daterange" align="right" unlink-panels
                range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions">
              </el-date-picker>
              <el-radio-group v-model="queryForm.dateradio" size="mini">
                <el-tooltip class="item" effect="dark" content="文件日期以 创建日期 为依据开始过滤" placement="top-start">
                  <el-radio-button border label="createTime">创建</el-radio-button></el-tooltip>
                <el-tooltip class="item" effect="dark" content="文件日期以  最后访问日期 为依据开始过滤" placement="top-start">
                  <el-radio-button border label="lastAccess">最后访问</el-radio-button></el-tooltip>
                <el-tooltip class="item" effect="dark" content="文件日期以 最后修改日期 为依据开始过滤" placement="top-start">
                  <el-radio-button border label="lastModified">最后修改</el-radio-button></el-tooltip>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="文件类型:" prop="fileExtension">

              <el-tooltip class="item" effect="dark" content="不需要加 '.' ,多个用 '|' 分隔 , 如: jpg|png|docx"
                placement="top-start">
                <el-input v-model="queryForm.fileExtension" placeholder="请输入文件后缀名" clearable></el-input>
              </el-tooltip>
            </el-form-item>
            <el-form-item>
              <el-tooltip class="item" effect="dark" :content="'过滤 '+selectPath.replace('file_','')+' 目录下的文件'"
                placement="top-start">
                <el-button type="primary" icon="el-icon-search" size="mini" :disabled="loading" v-loading="loading"
                  @click="eventChanageBuildView">搜
                  索</el-button>
              </el-tooltip>
              <el-tooltip class="item" effect="dark" content="重置过滤项和目录" placement="top-start">
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重 置</el-button> </el-tooltip>
            </el-form-item>
          </el-form>
        </el-card>
      </el-collapse-item>

    </el-collapse>
    <!-- </el-drawer> -->


    <div style="height: 10px;"> </div>
    <bar-chart :selectPath="selectShortPath" :folderTotal="folderTotal" :fileTotal="fileTotal"
      :totalSize="totalSize"></bar-chart>
    <el-card class="box-card"> <el-tooltip class="item" effect="dark"
        :content="'当前选择目录为:'+(selectPath.replace('file_',''))" placement="top-start">
        <el-divider content-position="left">
          <i class="el-icon-s-flag" style="color: #409EFF;"></i> {{(selectPath.replace("file_",""))}}
        </el-divider>
      </el-tooltip>
      <el-row :gutter="20">
        <!--树形目录数据-->
        <el-col :span="4" :xs="24">
          <el-card class="box-card">
            <div style=" overflow-x: auto; max-height: 760px; ">
              <div class="head-container">
                <el-tree :load="loadNode" lazy :data="localDirOptions" :props="defaultProps"
                  :filter-node-method="filterNode" ref="tree" node-key="label" highlight-current accordion
                  @node-click="handleNodeClick" />
              </div>
            </div>
          </el-card>
        </el-col>
        <!--用户数据-->
        <el-col :span="20" :xs="24">
          <el-row>
            <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
              <el-tab-pane label="文件容量" name="first">
                <div v-loading="loading" style="margin: 0 auto;"></div>
                <pie-chart @handleSetSetChartImage="handleSetSetChartImage" v-if="tabindex=='0'"
                  :text="selectPath.replace('file_','')" :subtext="'文件容量：（占上一层%）'" :chart-data="chartData" />
              </el-tab-pane>
              <el-tab-pane :label="'文件数量'" name="second">
                <div v-loading="loading" style="margin: 0 auto;"></div>
                <pie-chart v-if="tabindex=='1'" @handleSetSetChartImage="handleSetSetChartImage"
                  :text="selectPath.replace('file_','')" :subtext="'文件数量：（占上一层%）'" :chart-data="chartDataNumber" />
              </el-tab-pane>
              <el-tab-pane label="详细信息" name="third"> <el-table v-if="tabindex=='2'" :data="showTableData"
                  style="width: 100%">
                  <el-table-column prop="path" label="文件/文件夹">
                  </el-table-column>
                  <el-table-column sortable prop="size" width="120" label="容量">
                    <template slot-scope="scope">
                      <span style="margin-left: 10px">{{ (scope.row.size / queryForm.unitradio).toFixed(1) }}</span>
                    </template>

                  </el-table-column>
                  <el-table-column sortable prop="number" width="100" label="文件数量">

                  </el-table-column>
                  <el-table-column sortable prop="folderNumber" width="110" label="文件夹数量">
                  </el-table-column>
                  <el-table-column label="创建日期" width="180">
                    <template slot-scope="scope">

                      {{dateString(scope.row.createTime)}}
                    </template>
                  </el-table-column>
                  <el-table-column label="最后访问日期" width="180">
                    <template slot-scope="scope">

                      {{ dateString(scope.row.lastAccess) }}
                    </template>
                  </el-table-column>
                  <el-table-column label="最后修改日期" width="180">
                    <template slot-scope="scope">

                      {{dateString( scope.row.lastModified) }}
                    </template>
                  </el-table-column>

                </el-table>
                <el-pagination layout="prev, pager, next" @current-change="getDataTableList" :total="tableData.length">
                </el-pagination>
              </el-tab-pane>
              <el-tab-pane label="文件时长" name="fourth">
                <!-- {{summaryData}} -->
                <line-chart @handleSetSetChartImage="handleSetSetChartImage" v-if="tabindex=='3'"
                  :text="selectPath.replace('file_','')" :subtext="'文件容量'" :chart-data="summaryData" />
              </el-tab-pane>
            </el-tabs> </el-row>
        </el-col>

      </el-row>
    </el-card>
  </div>
</template>

<script>
  import axios from 'axios';
  import Treeselect from "@riophae/vue-treeselect";
  import requestSteam from '@/utils/requestSteam';
  import LineChart from '@/views/dashboard/LineChart'
  import PieChart from '@/views/dashboard/PieChart'
  import BarChart from '@/views/dashboard/PanelGroup'
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  import moment from 'moment';
  import {
    Notification,
    MessageBox,
    Message,
    Loading
  } from 'element-ui'
  import {
    listUser,
    getUser,
    delUser,
    addUser,
    updateUser,
    resetUserPwd,
    changeUserStatus,
    deptTreeSelect
  } from "@/api/system/user";

  import {
    Array
  } from 'core-js/web';
  import {
    listNasconfig,
    getNasconfig,
    delNasconfig,
    addNasconfig,
    updateNasconfig,
    testConnect,
    getCache,
    report
  } from "@/api/system/nasconfig";
  import {
    getToken
  } from "@/utils/auth";
  export default {
    name: 'SftpFiles',
    components: {
      PieChart,
      LineChart,
      BarChart
    },
    props: {
      nasconfig: {
        type: Object,
        default: () => ({})
      },
      dirOptions: {
        type: Array,
        default: () => ([])
      }
    },
    watch: {
      nasconfig: {
        deep: true,
        handler(val) {
          this.host = val.nasIp;
          this.port = val.port;
          this.user = val.username;
          this.password = val.password;
          this.path = val.path;
          this.initNas()
        }

      }
    },
    data() {
      return {

        reportImgUrl: '',
        drawer: false,
        showTableData: [],
        queryForm: {
          dateradio: "lastModified",
          unitradio: 1024,
          fileMaxSize: null,
          fileMinSize: null,
          fileExtension: null,
          dateTime: null
        },
        pickerOptions: {
          shortcuts: [{
            text: '最近一天',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24); // 减去一天
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '1天至1星期',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7); // 减去七天
              picker.$emit('pick', [start, end - 3600 * 1000 * 24]);
            }
          }, {
            text: '1星期至1月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30); // 减去一个月（约30天）
              picker.$emit('pick', [start, end - 3600 * 1000 * 24 * 7]);
            }
          }, {
            text: '1月至6月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 180); // 减去六个月（约180天）
              picker.$emit('pick', [start, end - 3600 * 1000 * 24 * 30]);
            }
          }, {
            text: '6月至1年',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 365); // 减去一年（约365天）
              picker.$emit('pick', [start, end - 3600 * 1000 * 24 * 180]);
            }
          }, {
            text: '1年至2年',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 730); // 减去两年（约730天）
              picker.$emit('pick', [start, end - 3600 * 1000 * 24 * 365]);
            }
          }, {
            text: '大于2年',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 730); // 减去两年（约730天）
              picker.$emit('pick', [new Date(start.getTime() - 3600 * 1000 * 24 * 730), start]);
            }
          }]
        },
        activeName: 'first',
        searchActiveName: 'first1',
        totalSize: 0,
        fileTotal: 0,
        folderTotal: 0,
        loading: false,
        tabindex: '0',
        chartData: {
          expectedData: [],
          actualData: [],
        },
        chartDataNumber: {
          expectedData: [],
          actualData: [],
        },
        deptName: "",
        defaultProps: {
          children: "children",
          label: "path",
          isLeaf: "type"
        },
        localDirOptions: this.dirOptions.slice(),
        connectType: "smb",
        host: '',
        port: "",
        user: '',
        password: '',
        url: "",
        selectPath: '',
        path: '',
        files: [],
        eventSource: null,
        processing: false, // 新增一个标志位，用于异步处理数据
        result: '',
        drawerShow: true,
        arrbreadcrumb: [],
        tableData: [],
        summaryData: {
          'ONE_DAY': 0,
          'ONE_DAY_TO_ONE_WEEK': 0,
          'ONE_WEEK_TO_ONE_MONTH': 0,
          'ONE_MONTH_TO_SIX_MONTHS': 0,
          'SIX_MONTHS_TO_ONE_YEAR': 0,
          'ONE_YEAR_TO_TWO_YEARS': 0,
          'GREATER_THAN_TWO_YEARS': 0
        },
        summaryData1: {
          'ONE_DAY': 0,
          'ONE_DAY_TO_ONE_WEEK': 0,
          'ONE_WEEK_TO_ONE_MONTH': 0,
          'ONE_MONTH_TO_SIX_MONTHS': 0,
          'SIX_MONTHS_TO_ONE_YEAR': 0,
          'ONE_YEAR_TO_TWO_YEARS': 0,
          'GREATER_THAN_TWO_YEARS': 0
        },
        selectShortPath: ''
      };
    },
    mounted() {
      this.$nextTick(() => {
        this.initNas()
      })
    },
    created() {
      //this.getDeptTree();
    },
    beforeDestroy() {
      this.localDirOptions = [];
      this.dirOptions = [];
      // 在组件销毁之前执行
      console.log('Component is about to be destroyed.')
      // 进行必要的清理工作，例如取消事件监听
    },
    destroyed() {
      // 在组件销毁之后执行
      console.log('Component has been destroyed.')
      // 执行一些逻辑，例如解除外部模型的绑定
    },
    methods: {
      /**
       * 报表下载
       */
      report() {
        if (this.tabindex == '3') {
          let param = {
            nasPath: this.selectPath,
            nasIp: this.host,
            reportImgUrl: this.reportImgUrl,
          }
          let combinedObj = {
            ...param,
            ...this.convertKeysToCamelCase(this.summaryData)
          };
          this.downloadReport('/system/nasconfig/export/report3', combinedObj,
            `nasconfig_${this.selectPath}report.xlsx`)
        } else {
          let param = {
            nasPath: this.selectPath,
            nasIp: this.host,
            reportImgUrl: this.reportImgUrl,
            fileInfoList: this.tableData
          }


          this.downloadReport('/system/nasconfig/export/report', param, `nasconfig_${this.selectPath}report.xlsx`)
        }
      },
      /**
       *事件变更构建视图
       */
      eventChanageBuildView() {
        switch (this.tabindex) {
          case "0":
            //改变容量视图
            this.builSizedCharView(this.tableData);
            break;
          case "1":
            this.buildTotelCharView(this.tableData);
            //改变文件数量视图
            break;
          case "2":
            //改变文件详细视图
            this.getDataTableList(1)
            break;
          case "3":
            //改变文件时长视图
            this.fetchFilesReportGenerator()
            break;
        }
      },

      /**
       * 创建文件总数图表视图
       *
       * @param {Object} arr
       */
      buildTotelCharView(arr) {
        // 对数组按 size 字段降序排序
        arr.sort((a, b) => b.size - a.size);

        // 将排序后的数组赋值给 tableData
        this.tableData = arr;

        // 创建一个函数来处理映射逻辑，以减少代码重复
        const mapItem = (item) => ({
          value: item.number,
          name: item.path,
        });

        // 使用 map 函数创建实际数据
        const numData = arr.map(mapItem);

        // 从映射过程中提取路径数据
        const expectedData = numData.map(item => item.name);

        // 组装最终的数据对象
        this.chartDataNumber = {
          expectedData: expectedData,
          actualData: numData
        };
      },
      /**
       * 创建文件容量图表视图
       *
       * @param {Object} arr
       */
      builSizedCharView(arr) {
        // 对数组按 size 字段降序排序，并且只保留前10个元素
        const topTenSortedArray = arr.sort((a, b) => b.size - a.size); //.slice(0, 10);

        // 将排序后的前10个元素赋值给 tableData
        this.tableData = topTenSortedArray;

        // 创建一个函数来处理映射逻辑，以减少代码重复
        const mapItem = (item) => ({
          value: (item.size / this.queryForm.unitradio).toFixed(1),
          name: item.path,
        });

        // 使用 map 函数创建实际数据
        const actualData = topTenSortedArray.map(mapItem);

        // 从映射过程中提取路径数据
        const expectedData = actualData.map(({
          name
        }) => name);

        // 组装最终的数据对象
        this.chartData = {
          expectedData: expectedData,
          actualData: actualData
        };

      },

      handleSetSetChartImage(base64) {
        this.reportImgUrl = base64;
        this.report();
      },
      getDataTableList(index) {
        index--;
        this.showTableData = this.tableData.slice(index * 10, (index + 1) * 10);
      },

      resetQuery() {
        this.queryForm = {
          dateradio: "lastModified",
          unitradio: 1024,
          fileMaxSize: null,
          fileMinSize: null,
          fileExtension: null,
          dateTime: null
        };
        this.checkDir();
      },
      dateString(timestamp) {
        return moment(timestamp).format('YYYY-MM-DD HH:mm:ss');
      },
      loadNode(node, resolve) {
        if (node.level === 0) {
          return resolve(this.localDirOptions);
        }
        let queryParams = {
          path: node.data.parent,
        }
        this.selectPath = node.data.parent;
        this.selectShortPath = node.data.path;
        getCache(queryParams).then(response => {
          let data = response.data;
          resolve(data);
          this.buildChar(data);
          this.eventChanageBuildView();
        });

      },
      handleRadioChange(e) {
        this.buildChar(this.localDirOptions);
        this.sizeSummaryDataFormat(this.summaryData1);
      },
      convertKeysToCamelCase(obj) {
        const camelCaseObj = {};
        for (const key in obj) {
          if (obj.hasOwnProperty(key)) {
            // 将下划线方式转换为驼峰式
            const camelKey = key
              .split('_')
              .map((word, index) =>
                index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
              )
              .join('');

            camelCaseObj[camelKey] = obj[key];
          }
        }
        return camelCaseObj;
      },

      handleClick(tab, event) {
        this.tabindex = tab.index;
        this.eventChanageBuildView();
      },
      handleClose(done) {
        done();
      },
      initNas() {
        if (this.localDirOptions.length) {
          this.buildChar(this.localDirOptions);
        } else if (this.nasconfig) {
          this.host = this.nasconfig.nasIp;
          this.port = this.nasconfig.port;
          this.user = this.nasconfig.username;
          this.password = this.nasconfig.password;
          this.path = this.nasconfig.path;
          this.selectShortPath = this.path;
          this.checkDir();
        }
      },
      filterNode(value, data) {
        if (!value) return true;
        return data.label.indexOf(value) !== -1;
      },
      // 节点单击事件
      handleNodeClick(node, resolve) {

      },
      buildBreadcrumb() {
        this.arrbreadcrumb = this.path.split("/");
      },



      buildChar(arr) {
        arr.sort((a, b) => b.size - a.size);
        this.tableData = arr;
        this.eventChanageBuildView()
        // 计算总容量数和总文件数
        let calculateTotals = (arr) => {
          let result = arr.reduce(
            (acc, item) => {
              acc.size = acc.size + (item.size / this.queryForm.unitradio);
              acc.number += item.number;
              acc.folderNumber += item.folderNumber;
              return acc;
            }, {
              size: 0,
              number: 0,
              folderNumber: 0
            }
          );
          return result;
        };
        // 使用 calculateTotals 函数计算总容量数和总文件数
        let totals = calculateTotals(arr);
        this.totalSize = totals.size;
        this.fileTotal = totals.number;
        this.folderTotal = totals.folderNumber;
      },


      sizeSummaryDataFormat(obj) {
        let summaryData = {
          ...obj
        }
        for (let key in summaryData) {
          if (summaryData.hasOwnProperty(key)) {
            summaryData[key] = (summaryData[key] / this.queryForm.unitradio).toFixed(1);
          }
        }
        this.summaryData = summaryData;
      },
      buildSeache(arr) {
        arr.sort((a, b) => b.size - a.size);
        this.tableData = arr;
        let size = 0;
        let totel = 0;
        this.getDataTableList(1);
      },
      checkDir(path) {
        this.selectPath = "file_" + this.host + "/" + this.path;
        this.buildBreadcrumb();
        this.loading = true;
        this.totalSize = 0;
        this.fileTotal = 0;
        this.localDirOptions = [];
        let onMessage = null;
        let onEnd = null;
        (async () => {
          try {
            const params = {
              host: this.host,
              port: this.port,
              user: this.user,
              password: this.password,
              path: this.path,
              url: this.url,
              connectType: this.connectType,
            }
            onMessage = (text) => {
              this.localDirOptions.push(text.value);
              this.buildChar(this.localDirOptions);
            };
            onEnd = (text) => {
              console.log('Received end');
              // 在这里处理结束消息
              this.loading = false;
              onMessage = null;
              onEnd = null;
            };
            await requestSteam.queryTextChat('/system/nasconfig/files-stream', params,
              onMessage, onEnd);
          } catch (error) {
            this.loading = false;
            this.$message({
              message: error,
              type: 'warning'
            });
            // alert(error)
            console.error('An error occurred during the chat query:', error);
          }
        })();
      },
      /**
       * 按照条件筛选每个文件
       */
      getCacheRecursion() {
        this.showTableData = [];
        this.tableData = [];
        let parm = this.queryForm;
        if (parm.dateTime) {
          parm.startDate = moment(parm.dateTime[0]).valueOf();
          parm.endDate = moment(parm.dateTime[1]).valueOf();
        }
        parm.path = this.selectPath;
        this.buildBreadcrumb();
        this.loading = true;
        this.totalSize = 0;
        this.fileTotal = 0;
        let arr = [];
        let onMessage = null;
        let onEnd = null;
        (async () => {
          try {
            onMessage = (text) => {
              arr = arr.concat(text.value)
              this.buildSeache(arr);
            };
            onEnd = (text) => {
              console.log('Received end');
              // 在这里处理结束消息
              this.loading = false;
              onMessage = null;
              onEnd = null;
            };
            await requestSteam.queryTextChat('/system/nasconfig/getCacheRecursion', parm,
              onMessage, onEnd);
            // 获取当前时间
            const now = new Date();
            // 输出小时、分钟和秒钟
            console.log(`redis select-end-当前时间为：${now.getHours()}小时 ${now.getMinutes()}分钟 ${now.getSeconds()}秒`);
          } catch (error) {
            this.loading = false;
            this.$message({
              message: error,
              type: 'warning'
            });
            // alert(error)
            console.error('An error occurred during the chat query:', error);
          }
        })();
      },

      buildReportGenerator(data) {
        for (const [range, size] of Object.entries(data)) {
          if (this.summaryData1.hasOwnProperty(range)) {
            this.summaryData1[range] += size;
          } else {
            this.summaryData1[range] = size;
          }
        }
        // this.sizeSummaryDataFormat(this.summaryData);
        this.summaryData = this.summaryData1;

      },
      /**
       * 取文件时长分组汇总统计
       */
      fetchFilesReportGenerator() {
        this.summaryData = {
          'ONE_DAY': 0,
          'ONE_DAY_TO_ONE_WEEK': 0,
          'ONE_WEEK_TO_ONE_MONTH': 0,
          'ONE_MONTH_TO_SIX_MONTHS': 0,
          'SIX_MONTHS_TO_ONE_YEAR': 0,
          'ONE_YEAR_TO_TWO_YEARS': 0,
          'GREATER_THAN_TWO_YEARS': 0
        };
        this.summaryData1 = {
          'ONE_DAY': 0,
          'ONE_DAY_TO_ONE_WEEK': 0,
          'ONE_WEEK_TO_ONE_MONTH': 0,
          'ONE_MONTH_TO_SIX_MONTHS': 0,
          'SIX_MONTHS_TO_ONE_YEAR': 0,
          'ONE_YEAR_TO_TWO_YEARS': 0,
          'GREATER_THAN_TWO_YEARS': 0
        };
        let parm = this.queryForm;
        parm.startDate = null;
        parm.endDate = null;
        if (parm.dateTime) {
          parm.startDate = moment(parm.dateTime[0]).valueOf();
          parm.endDate = moment(parm.dateTime[1]).valueOf();
        }
        parm.path = this.selectPath;
        this.loading = true;
        let arr = [];
        let onMessage = null;
        let onEnd = null;
        (async () => {
          try {
            onMessage = (text) => {
              arr = text.value
              this.buildReportGenerator(arr);
            };
            onEnd = (text) => {
              console.log('Received end');
              // 在这里处理结束消息
              this.loading = false;
              onMessage = null;
              onEnd = null;
            };
            await requestSteam.queryTextChat('/system/nasconfig/fetchFilesReportGenerator', parm,
              onMessage, onEnd);
            // 获取当前时间
            const now = new Date();

            this.sizeSummaryDataFormat(this.summaryData);
            // 输出小时、分钟和秒钟
            console.log(`redis select-end-当前时间为：${now.getHours()}小时 ${now.getMinutes()}分钟 ${now.getSeconds()}秒`);
          } catch (error) {
            this.loading = false;
            this.$message({
              message: error,
              type: 'warning'
            });
            // alert(error)
            console.error('An error occurred during the chat query:', error);
          }
        })();
      }
    },

  };
</script>

<style scoped>
  .loading {
    text-align: center;
  }

  .daohang {
    cursor: pointer;
  }

  .daohang:hover {
    color: #00aaff;
  }

  .el-table .warning-row {
    background: oldlace;
  }

  .center-title .el-collapse-item__header {
    text-align: center !important;
    border: 1px solid red;
  }

  .el-table .success-row {
    background: #f0f9eb;
  }
</style>
